package com.xone.xapp;

import org.json.JSONObject;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MarketActivity extends BasicActivity {
	
	@Override
	public int getContentView() {
		return R.layout.market;
	} 
	
	@Override
	public String getHeaderTitle() {
		return getTitleByLevel("逛逛市场");
	}
	/**
	 * 是否需要检测登录
	 * @return
	 */
	@Override
	public boolean isLoginCheck() {
		return false;
	}
	
	@Override
	public void leftButton(Button leftButton) {
		leftButton.setText("首页");
		leftButton.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(getContext(), GuideActivity.class);
				startActivity(i);
			}
		});
	}
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		View productType0 = findViewById(R.id.product_type_0);
		productType0.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(MarketActivity.this, ProductListActivity.class);
				i.putExtra("saleType", "0");
				startActivity(i);
			}
		});
		View productType1 = findViewById(R.id.product_type_1);
		productType1.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(MarketActivity.this, ProductListActivity.class);
				i.putExtra("saleType", "1");
				startActivity(i);
			}
		});
		View productType2 = findViewById(R.id.product_type_2);
		productType2.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(MarketActivity.this, ProductListActivity.class);
				i.putExtra("saleType", "2");
				startActivity(i);
			}
		});
		View purchaseType0 = findViewById(R.id.purchase_type_0);
		purchaseType0.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(MarketActivity.this, PurchaseListActivity.class);
				startActivity(i);
			}
		});
	}
	
	@Override
	public void onBackPressed() {
		super.onBackPressed();
	    this.finish();
	}
}
